<?php
/*
	支付宝小程序接口
*/
define('IN','custom');
require_once '../core/core.php';
$uniacid=intval($_POST['uniacid']);
$aliapp_id=intval($_POST['aliapp_id']);
if(!$aliapp_id || !$uniacid){
	exi('访问错误，关键参数缺失！','error');
}
$account=pdo_get('core_accounts',array('uniacid'=>$uniacid));
$aliapp=pdo_get('core_account_aliapp',array('id'=>$aliapp_id,'uniacid'=>$uniacid));
if(!$account || !$aliapp){
	exi('访问错误，找不到指定站点或者支付宝小程序！','error');
}
$_SESSION['uniacid']=$uniacid;
$_SESSION['aliapp_id']=$aliapp_id;
$_SESSION['token']=$_SESSION['token']?:random(30);
$_SESSION['base_key_str']=$_SESSION['base_key_str']?:str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_');
$res=array(
	'ssid'=>session_id(),
	'token'=>$_SESSION['token'],
	'base_key_str'=>$_SESSION['base_key_str'],
);
exi($res);